/**
 * 企业客户基本信息管理初始化
 */
var CommonCustomerInfo = {
    id: "CustCustomerInfoTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
CommonCustomerInfo.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '客户Id', field: 'id', visible: false, align: 'center', valign: 'middle'},
            {title: '公司名称', field: 'company', visible: true, align: 'center', valign: 'middle'},
            {title: '客户类型', field: 'customerType', visible: true, align: 'center', valign: 'middle'}
    ];
};

/**
 * 检查是否选中
 */
CommonCustomerInfo.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        CommonCustomerInfo.seItem = selected[0];
        return true;
    }
};

/**
 * 查询企业客户基本信息列表
 */
CommonCustomerInfo.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    CommonCustomerInfo.table.refresh({query: queryData});
};

CommonCustomerInfo.confirmSelect = function(){
    if(CommonCustomerInfo.check()){
        return CommonCustomerInfo.seItem;
    }
}

$(function () {
    var defaultColunms = CommonCustomerInfo.initColumn();
    var table = new BSTable(CommonCustomerInfo.id, "/custCustomerInfo/queryOpenList", defaultColunms);
    table.setPaginationType("server");
    table.showRefresh = false;
    table.showColumns = false;
    CommonCustomerInfo.table = table.init();
});
